import request from '../utils/request.js';

export function Login_API(username, password) {
    return request({
        url: '/user/login',
        method: 'POST',
        data: {
            username,
            password
        }
    })
}

export function Register_API(userInfo) {
    return request({
        url: '/user/register',
        method: 'POST',
        data: {
            username: userInfo.username,
            password: userInfo.password,
            nickname: userInfo.nickname,
            email: userInfo.email,
            avatar: userInfo.avatar
        }
    })
}

export function GetUserInfo_API() {
    return request({
        url: '/user/info',
        method: 'GET',
        headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
        }
    })
}

export function GetUserSearch_API(username) {
    return request({
        url: `/user/search?username=${username}`,
        method: 'GET',
        headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
        }
    })
}

export function GetUserInfoById_API(id) {
    return request({
        url: `/user/info/target?id=${id}`,
        method: 'GET',
        headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
        }
    })
}

export function VerifyToken_API() {
    return request({
        url: '/user/verify',
        method: 'GET',
        headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
        }
    })
}